//import Vue from 'vue'
import axios from 'axios'
import qs from 'qs'
// Vue.prototype.axios = axios
var instance =axios.create({
    baseURL:'https://www.easy-mock.com/mock/5ba2f11cd7546c5ec0a7b913/food',
    timeout: 1000,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
      }
    
})
//instance.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
instance.interceptors.request.use(config=>{

     return config;
 },err=>{ 
     
 });
 // 响应时
 instance.interceptors.response.use(response => response, err => Promise.resolve(err.response))
export default {
   request(url,params,method="post"){
        return new Promise((resolve,reject)=>{
            instance({
                url:url,
                data:qs.stringify(params),
                method:method
            }).then(res=>{
                resolve(res)
            }).catch(err=>{
                reject(err)
            })
        })
   }
}
